package com.tools.common.container.r;

import com.tools.common.container.MapEntry;
import com.tools.common.exception.InvalidOperationException;
import com.tools.common.object.Note;

import java.util.Map;

/**
 * Map.Entry 接口的只读特性实现
 * */
@Note("Map.Entry 接口的只读特性实现")
public final class OnlyReadMapEntry<K, V> extends MapEntry<K, V> {

    public OnlyReadMapEntry(K key, V value) {
        super(key, value);
    }

    public OnlyReadMapEntry(Map.Entry<K, V> entry) {
        super(entry);
    }

    @Override
    public V setValue(V value) {
        throw new InvalidOperationException("该条目只允许读操作");
    }
}
